#include <iostream>

#include "cgicc/CgiDefs.h"
#include "cgicc/Cgicc.h"
#include "cgicc/HTTPHTMLHeader.h"
#include "cgicc/HTMLClasses.h"

using namespace std;
using namespace cgicc;

int main()
{
    try
    {
	Cgicc formData;

	cout << HTTPHTMLHeader() << endl;
	cout << HTMLDoctype(HTMLDoctype::eStrict) << endl;

	// html part
	cout << html().set("lang", "zh-cn").set("dir", "LTR") << endl;

	// head part
	cout << head() << endl
	     << title("Hello world") << endl
	     << meta().set("http-equiv", "Content-Type").set("content", "text/html") << endl
	     << meta().set("http-equiv", "charset").set("content", "utf-8") << endl << endl
	     << head() << endl;
	
	// body part
	cout << body() << endl;
	cout << h1("Login Page") << endl;
	cout << form().set("action", "/cgi-bin/verify").set("method", "post") << endl;
	cout << p() << endl;
	cout << "Username"; 
	cout << input().set("type", "text").set("name", "usr") << endl;
	cout << p() << endl;

	cout << p() << endl;
	cout << "Password"; 
	cout << input().set("type", "password").set("name", "pwd") << endl;
	cout << p() << endl;

	cout << p() << endl;
	cout << input().set("type", "submit").set("value", "register").set("name", "submitType") << endl;
	cout << input().set("type", "submit").set("value", "login").set("name", "submitType") << endl;
	cout << p() << endl;
	
	cout << form() << endl;
	cout << body() << endl;
	cout << html() << endl;
    }
    catch(exception& e)
    {
	cout << "ERROR!!" << endl;
    }
    return 0;
}
